//
//  MainViewController.swift
//  SwiftStudyDemoAll
//
//  Created by BINGO on 2019/5/12.
//  Copyright © 2019 mrlong. All rights reserved.
//

import UIKit


/*
 主界面
 */
class MainViewController: UIViewController ,UITableViewDelegate,UITableViewDataSource{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.dataStr.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: self.cell, for: indexPath)
        cell.textLabel?.text = self.dataStr[indexPath.row]
        return cell
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        switchView(i: indexPath.row)
    }
    
    
    let cell = "tableCell"
    let dataStr:Array<String> = ["FMDB_SQL"]
    override func viewDidLoad() {
        super.viewDidLoad()

        let main = TGLinearLayout.init(frame: self.view.frame, orientation: .vert)
        let tableView = UITableView.init(frame: main.frame)
        tableView.delegate = self
        tableView.dataSource = self
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: self.cell)
        
        main.addSubview(tableView)
        self.view.addSubview(main)
    }
    
    func switchView(i:Int) -> Void {
        switch i {
        case 0:
            //go sql
            self.present(ViewController.init(), animated: true, completion: nil)
            break
        default:
            
            break
        }
    }
}
